project(Pad)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake_modules/")
Include (CheckCXXSourceCompiles)

find_package(Qt4 REQUIRED)
find_package(INDI REQUIRED)
find_package(Nova REQUIRED)
find_package(ZLIB REQUIRED)

# qjoypad stuff
set (QJOYPAD_DIR ${CMAKE_SOURCE_DIR}/joystick/qjoypad-4.1.0/src/)
set (QJOYPAD_SRCS ${QJOYPAD_DIR}/axis.cpp ${QJOYPAD_DIR}/axis_edit.cpp ${QJOYPAD_DIR}/axisw.cpp ${QJOYPAD_DIR}/button.cpp 
     ${QJOYPAD_DIR}/button_edit.cpp ${QJOYPAD_DIR}/buttonw.cpp ${QJOYPAD_DIR}/event.cpp ${QJOYPAD_DIR}/flash.cpp 
     ${QJOYPAD_DIR}/getkey.cpp ${QJOYPAD_DIR}/icon.cpp ${QJOYPAD_DIR}/joypad.cpp ${QJOYPAD_DIR}/joypadw.cpp 
     ${QJOYPAD_DIR}/joyslider.cpp ${QJOYPAD_DIR}/keycode.cpp ${QJOYPAD_DIR}/layout.cpp ${QJOYPAD_DIR}/layout_edit.cpp 
     ${QJOYPAD_DIR}/quickset.cpp)

set (QJOYPAD_HEADERS ${QJOYPAD_DIR}/axis.h ${QJOYPAD_DIR}/axis_edit.h ${QJOYPAD_DIR}/button.h ${QJOYPAD_DIR}/button_edit.h 
     ${QJOYPAD_DIR}/flash.h ${QJOYPAD_DIR}/getkey.h ${QJOYPAD_DIR}/icon.h ${QJOYPAD_DIR}/joypad.h ${QJOYPAD_DIR}/joypadw.h 
     ${QJOYPAD_DIR}/keycode.h ${QJOYPAD_DIR}/layout.h ${QJOYPAD_DIR}/layout_edit.h)

set (QJOYPAD_RESOURCES joystick/res_qjoypad.qrc)

set_property(
   DIRECTORY
   PROPERTY COMPILE_DEFINITIONS ICON24=":/qjoypad/icon24.png" ICON64=":/qjoypad/icon64.png" DEVDIR="/dev/input"
   )

find_package(X11 REQUIRED)

#end qjoypad

include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${INDI_INCLUDE_DIR} ${NOVA_INCLUDE_DIR} 
                    ${X11_INCLUDE_DIR} ${QJOYPAD_DIR} ${CMAKE_SOURCE_DIR})

set(Pad_SRCS  MountDisplay.cpp Pad.cpp QJoypadIndi.cpp HCSettings.cpp HandController.cpp HCINDI.cpp main.cpp)
set(LibPad_SRCS  MountDisplay.cpp Pad.cpp QJoypadIndi.cpp HCSettings.cpp HandController.cpp HCINDI.cpp)
set(Pad_FORMS MountDisplay.ui Pad.ui HCSettings.ui HandController.ui)
set(Pad_HEADERS MountDisplay.h Pad.h QJoypadIndi.h HCSettings.h HandController.h HCINDI.h)
set(Pad_RESOURCES res_pad.qrc)


qt4_wrap_cpp(Pad_HEADERS_MOC ${Pad_HEADERS} ${QJOYPAD_HEADERS})
qt4_wrap_ui(Pad_FORMS_HEADERS ${Pad_FORMS})
qt4_add_resources(Pad_RESOURCES_RCC ${Pad_RESOURCES} ${QJOYPAD_RESOURCES})

add_executable(Pad ${Pad_SRCS} ${Pad_HEADERS_MOC} ${Pad_FORMS_HEADERS} ${Pad_RESOURCES_RCC} ${QJOYPAD_SRCS})
add_library(HCINDI ${LibPad_SRCS} ${Pad_HEADERS_MOC} ${Pad_FORMS_HEADERS} ${QJOYPAD_SRCS} ${Pad_RESOURCES_RCC})

target_link_libraries(Pad ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${INDI_LIBRARIES} ${INDI_CLIENT_LIBRARIES} ${NOVA_LIBRARIES} ${X11_LIBRARIES} ${X11_XTest_LIB} ${ZLIB_LIBRARY})

install(TARGETS Pad RUNTIME DESTINATION bin)

